import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
import 'package:http/http.dart' as http;

class Loading_screen extends StatefulWidget {
  const Loading_screen({super.key});

  @override
  State<Loading_screen> createState() => _Loading_screenState();
}

class _Loading_screenState extends State<Loading_screen> {

  void getLocation() async {
    // 获取gps位置, 因为不一定保证能够获取用户的地址位置，
    // 所以这里获取位置要用try， catch来执行，获取不到就抛出错误
    LocationPermission permission = await Geolocator.requestPermission();
    Position position = await Geolocator.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
  }

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      onPressed: () {
        getLocation();
      },
      child: Text('Get Location'),
    );
  }
}
